﻿
@{
    ViewBag.Title = "Role";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@model Webdiyer.WebControls.Mvc.PagedList<OneStationFile.Model.Role>
@using Webdiyer.WebControls.Mvc;
<div id="page-wrapper">
    <div class="row">
        <h1 class="page-header">角色管理</h1>

        <!-- /.col-lg-12 -->
    </div>
    <!-- /.row -->
    <!-- /.row -->
    <div class="row">

        <!-- /.col-lg-6 -->
        <div class="col-lg-12">
            <div class="panel panel-default">
                <nav class="navbar navbar-default" role="navigation">
                    <div class="container-fluid">
                        <div class="navbar-header">
                            <h3 style="margin:10px,0px,20px">条件筛选</h3>
                        </div>
                        <div>
                            <table class="table">
                            @using (Html.BeginForm("index", ViewContext.RouteData.GetRequiredString("Controller"), new RouteValueDictionary { { "id", Request["id"] } }, FormMethod.Get, new { @class = "navbar-form navbar-left" }))
                            {   <tbody>
                                    <tr class="danger">
                                        <td><input name="kwName" value="@Request["kwName"]" class="form-control input-group-sm" placeholder="名称"></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                    </tr>
                                    <tr class="danger">
                                        <td>
                                            <input type="button" class="btn btn-default" onclick="Add()" value="添加"  />
                                        </td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td style="text-align:right">
                                            <button type="submit" class="btn btn-default">搜索</button>
                                        </td>
                                    </tr>

                                </tbody>
                            }
                            </table>
                            @*<div class="form-group">
                                        <input type="text" name="NameKeyWord" value="@Request["NameKeyWord"]" class="form-control" placeholder="培训班名称" style="width:200px">
                                       <span><input type="text" name="NameKeyWord" value="@Request["NameKeyWord"]" class="form-control" placeholder="培训班名称" style="width:200px"></span>
                                    </div>
                                    <button type="submit" class="btn btn-default">搜索</button>
                                <button type="button" onclick="add()" class="btn btn-default navbar-btn">
                                    添加
                                </button>*@

                        </div>
                    </div>
                </nav>
                <!-- /.panel-heading -->
                <div class="panel-body">
                    <div class="table-responsive">
                        <table class="table">
                            <thead>
                                <tr>
                                    <th>#</th>
                                    <th>名称</th>
                                    <th>描述</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                @{ int i = 0;}
                                @foreach (var item in Model)
                                 {
                                     <tr class="success">
                                        <td>@(++i)</td>
                                        <td><a href="/Role/Nodes?id=@item.Id">@item.Name</a></td>
                                         <td>@item.Describe</td>
                                        <td>
                                            <a href="javascript:Edit(@item.Id)">修改 </a> 
                                            <a href="javascript:Delete(@item.Id)">删除</a>
                                        </td>
                                    </tr>
                                 }






                            </tbody>
                        </table>
                        @Html.Pager(Model, new PagerOptions { PageIndexParameterName = "page", NumericPagerItemCount = 5, ContainerTagName = "ul", CssClass = "pagination", CurrentPagerItemTemplate = "<li class=\"active\"><a href=\"#\">{0}</a></li>", DisabledPagerItemTemplate = "<li class=\"disabled\"><a>{0}</a></li>", PagerItemTemplate = "<li>{0}</li>", Id = "pager2", PageIndexBoxId = "pageIndexBox", GoToButtonId = "goToBtn", NavigationPagerItemsPosition = PagerItemsPosition.Left })
                    </div>
                    <!-- /.table-responsive -->
                </div>
                <!-- /.panel-body -->
            </div>
            <!-- /.panel -->
        </div>
        <!-- /.col-lg-6 -->
    </div>
    <!-- /.row -->
</div>


@section scripts{
    <script>
        //添加用户
        function Add() {
            art.dialog.open("/Role/Edit", { id: 'memdiv', width: 900, height: 500, title: '添加角色' });
        }
        //end
        //修改用户
        function Edit(id) {
            art.dialog.open("/Role/Edit?id=" + id, { id: 'memdiv', width: 900, height: 500, title: '修改角色' });
        }
        //end
        //删除用户
        function Delete(id) {
            art.dialog.confirm('你确定要删除这条消息吗？', function () {
                $.post("/Role/Delete", { id: id }, function (result) {
                    
                    art.dialog.tips(result.msg);
                    if (result.res == true) {
                        setTimeout(function () { window.location.reload() }, 1000);
                    }
                }, "json");
            }, function () {
                art.dialog.tips('用户取消了操作');
            });

        }
        //end
    </script>
}

